home *** CD-ROM | disk | FTP | other *** search
/ Biodiversity of Illinois 2: Woodland Habitats / Biodiversity of Illinois 2 - Woodland Habitats.iso / mac / casts / PDFxtraBehaviors.cst / 00003_Script_PDF_Open < prev    next >
Text File  |  2006-07-11  |  7KB  |  145 lines

  1. -- Open
  2.  
  3. Property pEvent, pSprite, pFileName, pPathType, pEnableUpdateFromURL, pUpdateFromURL, pPage, pZoom, pScale, pDisplayMode, pToolbar, pScrollbars, pScrollH, pScrollV, pAlertFlag
  4.  
  5. on doOpen me
  6.   if (pFileName="") then exit
  7.   case pZoom of:
  8.     "Fit Width": set zm = #fitWidth
  9.     "Actual Size": set zm = #actualSize
  10.     "Fit Page": set zm = #fitPage
  11.     "Fit Visible": set zm = #fitVisible
  12.     otherwise: 
  13.       if (pScale<8) or (pScale>1600) then
  14.         alert "Invalid zoom value"
  15.         exit
  16.       else
  17.         set zm = pScale
  18.       end if
  19.   end case
  20.   
  21.   case pDisplayMode of:
  22.     "Pages Only": set dm = #pagesOnly
  23.     "Bookmarks and Pages": set dm = #bookmarkAndPages
  24.     "Thumbnails and Pages": set dm = #thumbnailAndPages
  25.   end case
  26.   set err = PDF_Open(sprite pSprite, pFileName, [#pathtype: pPathType, #EnableUpdateFromURL: pEnableUpdateFromURL, #UpdateFromURL: pUpdateFromURL, #DisplayOption: #customdisplayoptions, #page:pPage, #zoom:zm, #displayMode:dm, #toolbar:pToolbar, #scrollBars:pScrollbars, #scrollH:pScrollH, #scrollV:pScrollV])
  27.   if PDF_status(sprite pSprite) then alert "PDF Behavior Error"&RETURN&PDF_error(sprite pSprite)
  28. end doOpen
  29.  
  30. on mouseUp me
  31.   if (pEvent = #mouseUp) then doOpen(me)
  32. end mouseUp
  33.  
  34. on mouseDown me
  35.   if (pEvent = #mouseDown) then doOpen(me)
  36. end mouseDown
  37.  
  38. on prepareFrame me
  39.   if (pEvent = #prepareFrame) then doOpen(me)
  40. end prepareFrame
  41.  
  42. on beginsprite me
  43.   if (pEvent = #beginsprite) then doOpen(me)
  44. end beginsprite
  45. -- standard behavior stuff --
  46. on getPropertyDescriptionList me
  47.   set defaultValues = GetDefaultValues (me)
  48.   
  49.   set pdfSpriteList = getProp (defaultValues, #spriteList)
  50.   set defSprite     = getProp (defaultValues, #defaultSprite)
  51.   if (defSprite=0) then
  52.     if the ticks - pAlertFlag > 10 then
  53.       alert "Please create a sprite of type PDF first."
  54.     end if
  55.     set pAlertFlag = the ticks -- The ticks when the user clicked "OK"
  56.     
  57.     set defSprite     = ""
  58.     set pdfSpriteList = [defSprite]
  59.     -- should I exit or not?
  60.     exit
  61.   end if
  62.   set p_list = [:]
  63.   addprop p_list, #pEvent, [ #comment: "Event", #format:#symbol, #range:[#mouseUp, #mouseDown, #prepareFrame, #beginsprite], #default:#mouseUp]
  64.   addprop p_list, #pSprite, [ #comment: "PDF Sprite is in channel:", #format:#symbol, #range:pdfSpriteList, #default:defSprite]
  65.   addprop p_list, #pFileName, [ #comment: "PDF file path:", #format:#string, #default:".pdf" ]
  66.   addprop p_list, #pPathType, [ #comment: "Path is:", #format: #symbol,#range: [ "Absolute or URL", "Relative to Movie", "Relative to Playback Engine" ], #default: "Absolute or URL" ]
  67.   addprop p_list, #pEnableUpdateFromURL, [ #comment: "Enable update URL:", #format:#boolean, #default:FALSE ]
  68.   addprop p_list, #pUpdateFromURL, [ #comment: "Update URL (if enabled):", #format:#string, #default:"http://" ]
  69.   addprop p_list, #pPage, [ #comment: "Start at page:", #format: #integer, #default:1 ]
  70.   addprop p_list, #pZoom, [ #comment: "Start at zoom:", #format:#symbol, #range:["Fit Width", "Actual Size", "Fit Page", "Fit Visible", "Other (specify below)"], #default:"Fit Width"]
  71.   addprop p_list, #pScale, [ #comment: "Other zoom (8..1600):", #format:#integer, #default:""]
  72.   addprop p_list, #pDisplayMode, [ #comment: "Display mode:", #format:#symbol, #range:["Pages Only", "Bookmarks and Pages", "Thumbnails and Pages"],#default:"Pages Only" ]
  73.   addprop p_list, #pToolbar, [ #comment: "Show Toolbar:", #format:#boolean, #default:TRUE ]
  74.   addprop p_list, #pScrollbars, [ #comment: "Show Scrollbars:", #format:#boolean, #default:TRUE ]
  75.   addprop p_list, #pScrollH, [ #comment: "Scroll H:", #format: #integer, #default:0 ]
  76.   addprop p_list, #pScrollV, [ #comment: "Scroll V:", #format: #integer, #default:0 ]
  77.   return p_list
  78. end
  79.  
  80. on getBehaviorDescription
  81.   tmp = "Link a PDF document to the designated PDF Xtra sprite. If the sprite is already linked to a PDF document, that document is first closed and then the new one opened." & RETURN& "All platforms."
  82.   tmp = tmp &RETURN&RETURN& "--- PARAMETERS --- "   
  83.   tmp = tmp &RETURN& " - Event: mouseUp, mouseDown, prepareFrame, or beginSpritePDF"
  84.   tmp = tmp &RETURN& " - Sprite is in channel: which channel contains the PDF Sprite"
  85.   tmp = tmp & RETURN& " - PDF file path: a string that contains the relative or full path and file name of the PDF document to open."
  86.   tmp = tmp & RETURN& " - Path is: Absolute or URL, Relative to Movie, Relative to Playback Engine."
  87.   tmp = tmp & RETURN& " - Enable update URL: If this box is checked, there must be a valid URL in the Update URL field."
  88.   tmp = tmp & RETURN& " - Update URL: The URL containing the PDF document to download if the local one is older."
  89.   tmp = tmp & RETURN& " - Start at page: Which page of the document should be displayed on opening."
  90.   tmp = tmp & RETURN& " - Start at zoom: Fit Width, Actual Size, Fit Page, Fit Visible, Other."
  91.   tmp = tmp & RETURN& " - Other zoom (8..1600): A number representing the percentage to scale the document."
  92.   tmp = tmp & RETURN& " - Display mode: Pages Only, Bookmark And Pages, or Thumbnail And Pages"
  93.   tmp = tmp & RETURN& " - Show Toolbar: Display toolbar if checked (to show the toolbar in Director, the PDF document must have been saved in Acrobat, with the toolbar showing); hide the toolbar otherwise."
  94.   tmp = tmp & RETURN& " - Show Scrollbars: Display scrollbars if checked; hide scrollbars otherwise." & RETURN & " - Scroll H: Set the horizontal scroll position to the number of pixels specified."
  95.   tmp = tmp & RETURN& " - Scroll V: Set the vertical scroll position to the number of pixels specified."
  96.   tmp = tmp &RETURN&RETURN& "Free to use and abuse. (c)1999-2005, Integration New Media, Inc." &RETURN& "Thanks to James Newton for his suggestions."  
  97.   return tmp  
  98. end
  99. on getBehaviorTooltip
  100.   return "Attached to a button, background object." &RETURN& "Link a PDF document to the designated PDF Xtra sprite." &RETURN& "If the sprite is already linked to a PDF document," &RETURN& "that document is first closed and then the new one opened." & RETURN& "All platforms."
  101.   
  102. end
  103.  
  104. -- utils --
  105.  
  106. on GetDefaultValues me
  107.   if the currentSpriteNum then
  108.     set spriteList = GetSpriteList (me #PDF)
  109.     if count (spriteList) then
  110.       set defaultSprite = getAt (spriteList, 1)
  111.     else
  112.       set defaultSprite = 0
  113.     end if
  114.     
  115.     return [#spriteList: spriteList, #defaultSprite: defaultSprite]
  116.     
  117.   else -- the currentSpriteNum = 0
  118.     -- Director is merely recompiling this script: return dummy values
  119.     return [#spriteList: [1], #defaultSprite: 1]
  120.   end if
  121. end 
  122.  
  123.  
  124. on GetSpriteList me, memberType
  125.   -- return list of sprites of type memberType in current frame
  126.   global version
  127.   if (char 1 of version = 6) then
  128.     set maxSprite = 120
  129.   else
  130.     set maxSprite = the lastChannel
  131.   end if
  132.   
  133.   set aList=[]
  134.   
  135.   repeat with i = 1 to maxSprite
  136.     set spriteMember = the member of sprite i
  137.     if (the type of spriteMember = memberType) then
  138.       append (aList, i)
  139.     end if
  140.   end repeat
  141.   
  142.   return aList
  143. end GetSpriteList
  144.  
  145.